package informationsystem

import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.decoder.RESTLayerList;
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;

import java.sql.Connection;
import java.util.List;


class HomeService {
	boolean transactional = true
	
	def REST_URL = "http://localhost:8080/geoserver/wms"
	
	def getWMSInfo(){
		try {
			URL url = new URL(REST_URL)
			def connection = url.openConnection()
			connection.setRequestMethod("GET")
			def parameters = "service=wms&request=GetCapabilities&version=1.1.1"
			connection.doOutput = true
			Writer wr = new OutputStreamWriter(connection.outputStream)

			wr.write(parameters)
			wr.flush()
			wr.close()
			connection.connect();
			return connection.content.text;
		}
		catch (e) {
			return null
		}
	}
}
